<template>
  <d-scroll-view  @refresherrefresh="getDetail" :refresher-triggered="triggered">
    <proj-detail-layout :process-instance-id="processInstanceId" :project-number="projectNumber">
    <d-forms label-width="200rpx">
      <d-forms-item label="销售经理">
        <pm-user-select disabled :user-id="form.salesManager"></pm-user-select>
      </d-forms-item>
      <d-forms-item label="售前部门经理">
        <pm-user-select disabled :user-id="form.preManager"></pm-user-select>
      </d-forms-item>
      <d-forms-item label="商务部门经理">
        <pm-user-select disabled :user-id="form.businessManager"></pm-user-select>
      </d-forms-item>
      <view>
        <text class="form-title-1">投标信息</text>
        <d-card style="margin-bottom: 20rpx;" v-for="(item, idx) in form.biddingDocumentsListRespVOS" :key="'bidDoc_'+idx">
          <d-forms disabled label-width="200rpx">
            <d-forms-item label="投标单位名称" :input="item.biddingUnitName"></d-forms-item>
            <d-forms-item label="投标标价" :type="DFormInputType.AMOUNT" :input="item.tenderOffer"></d-forms-item>
            <d-forms-item label="备注" :input="item.remarksColumn"></d-forms-item>
            <view>
              <text class="form-title-2">投标文件</text>
              <pm-file-upload readonly :files="item.fileName"></pm-file-upload>
            </view>
          </d-forms>
        </d-card>
      </view>
    </d-forms>
  </proj-detail-layout>
  </d-scroll-view>
</template>

<script setup lang="ts">
import ProjDetailLayout from "@/components/ProjDetailLayout/index.vue";
import {useBidTaskReviewApi} from "@/api/pm/project/bidTaskReview";
import {DFormInputType} from "@/utils/enum";

defineOptions({ name: 'BidTasksReview' })

const initForm = {
  projectNumber: null,
  storaged: null,
  id: null,
  projectName: null,
  resultCause: null,
  projectGrade: null,
  salesManager: null,
  preManager: null,
  businessManager: null,
  userId: null,
  processInstanceId: null,
  result: null,
  status: null,
  biddingDocumentsListRespVOS: null,
}
const form = ref<BidTaskReviewForm>(initForm)
const triggered = ref<boolean>(false);
function getDetail() {
  if (projectNumber.value) {
    triggered.value = true;
    useBidTaskReviewApi().getBidReviewByProjNum(projectNumber.value).then(res => {
      if (res.code === 0 && res.data) {
        form.value = res.data
      }
    }).finally(() => {
      triggered.value = false;
    })
  }
}

const projectNumber = ref<string>(null);
const processInstanceId = ref<string>(null);
onLoad((query) => {
  projectNumber.value = query['project_number']
  processInstanceId.value = query['process_instance_id']
  getDetail();
})
</script>

<style scoped lang="scss">

</style>
